package base

import "jvmgo/ch09/rtda"
import "jvmgo/ch09/rtda/heap"

//创建新的帧，推入虚拟机栈顶
func InvokeMethod(invokerFrame *rtda.Frame, method *heap.Method) {

    thread := invokerFrame.Thread()
    newFrame := thread.NewFrame(method)
    thread.PushFrame(newFrame)

    argSlotSlot := int(method.ArgSlotCount())
    if argSlotSlot > 0 {
        for i := argSlotSlot - 1; i >= 0; i-- {
            slot := invokerFrame.OperandStack().PopSlot()
            newFrame.LocalVars().SetSlot(uint(i), slot)
        }
    }
}